<!doctype html>
<html>
    <head>
        <title>VideoTrack.selected change</title>
        <script src="../../resources/testharness.js"></script>
        <script src="../../resources/testharnessreport.js"></script>
            </head>
    <body>
        <script>
            async_test(function(t)
            {
                var video = document.createElement("video");
                video.src = "../content/test.ogv";

                video.onloadedmetadata = t.step_func(function()
                {
                    assert_equals(video.videoTracks.length, 1, "videoTracks.length");
                    assert_equals(video.videoTracks.selectedIndex, 0, "videoTracks.selectedIndex (initial)");
                    assert_true(video.videoTracks[0].selected, "videoTrack.selected (initial)");
                    video.videoTracks[0].selected = false;
                    assert_equals(video.videoTracks.selectedIndex, -1, "videoTracks.selectedIndex (first setter)");
                    assert_false(video.videoTracks[0].selected, "videoTrack.selected (first setter)");

                    video.videoTracks.onchange = t.step_func(function()
                    {
                        assert_false(video.videoTracks[0].selected, "videoTrack.selected (first setter)");
                        video.videoTracks[0].selected = true;
                        assert_equals(video.videoTracks.selectedIndex, 0, "videoTracks.selectedIndex (second setter)");
                        assert_true(video.videoTracks[0].selected, "videoTrack.selected (second setter)");

                        video.videoTracks.onchange = t.step_func_done(function()
                        {
                            assert_equals(video.videoTracks.selectedIndex, 0, "videoTracks.selectedIndex (change event)");
                            assert_true(video.videoTracks[0].selected, "videoTrack.selected (change event)");
                        });
                    });
                });
            }, "VideoTrackList track change");
        </script>
    </body>
</html>
